package com.travelranking.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name="TRAVEL")
@NamedQueries({
	@NamedQuery(name="getAllTravels", query="from TravelEntity te order by te.rank desc")
})

public class TravelEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	private Long id;
	private CityEntity city; 
	private String opinion;
	private Integer rank;
	
	public TravelEntity() {
		rank = 0;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@ManyToOne(targetEntity=CityEntity.class)
	public CityEntity getCity() {
		return city;
	}

	public void setCity(CityEntity city) {
		this.city = city;
	}

	
	@Column(name="OPINION")
	public String getOpinion() {
		return opinion;
	}

	public void setOpinion(String opinion) {
		this.opinion = opinion;
	}

	@Column(name="RANK")
	public Integer getRank() {
		return rank;
	}

	public void setRank(Integer rank) {
		this.rank = rank;
	}

	
}
